package com.wimcorp.magic.color;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;


@Embeddable
public class ColorHolder {

	
	@ElementCollection(fetch=FetchType.EAGER)
	private Set<Integer> colors = new HashSet<Integer>();

	
	public void addColor(Color color) {
		colors.add(color.ordinal());
	}

	public void removeColor(Color color) {
		colors.remove(color);
	}

	public Set<Color> getColors() {
		Set<Color> colorList = new HashSet<Color>();
		for(Integer c : colors){
			colorList.add(Color.values()[c]);
		}
		return colorList;
	}

	public String toString() {
		StringBuilder color = new StringBuilder();
		for (Integer c : colors) {			
			color.append(Color.values()[c].getColor());
		}
		return color.toString();
	}
	
}
